<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Gift_logModel extends Model {

    public function search($key_word) {

        $where['username'] = array('like', '%' . $key_word . '%');

        $where['title'] = array('like', '%' . $key_word . '%');
        

        $where['uid'] = array('like', '%' . $key_word . '%');
        
        $where['nicheng'] = array('like', '%' . $key_word . '%');
        $where['_logic'] = 'or';

        $map['_complex'] = $where; 

        $map['review']  = array( 'eq' ,1); 


        $arr = $this->field('uid,username,title,nicheng,portrait,category_id')->where($map)->findAll();
        
        
        $cate=D('Category');
        
          foreach ($arr as $key => $val) {
              $cate_arr=$cate->get_category($val[category_id]);
                $arr[$key]['category_name']=$cate_arr[cate_name];
            }
        

        return $arr;
    }

}
